﻿using System.Collections.Generic;
using UnityEngine;
/*你要干嘛？*/
public class Test_Input : MonoBehaviour
{
    //获取鼠标输入
    private void Update1()
    {
        if (Input.GetMouseButtonDown(0))
        {
            print("按下鼠标左键");
            transform.position = transform.position + new Vector3(0,1,0);
        }
        if (Input.GetMouseButtonDown(1))
        {
            print("按下鼠标右键");
        }
        if (Input.GetMouseButton(0))
        {
            print("按住鼠标左键");
            print(Input.mousePosition);//输出鼠标位置
        }
    }
    //获取按键输入
    private void Update2()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            print("按下W");
        }
        if (Input.GetKey(KeyCode.S))
        {
            print("按住S");
        }
        if (Input.GetKeyUp(KeyCode.S))
        {
            print("抬起S");
        }
    }
    //演示获取虚拟按键
    private void Update3()
    {
        if (Input.GetButtonDown("Skill1"))
        {
            print("按下了技能一");
        }
    }
    //演示获取虚拟轴  水平：Horizontal 垂直：Vertical
    private void Update4()
    {
        //正方向返回1，负方向返回-1
        float h = Input.GetAxis("Horizontal");//轴区分大小写
        float v = Input.GetAxis("Vertical");
        Vector3 direction = new Vector3(h, 0, v).normalized;//normalized让向量长度变为1
        transform.Translate(direction*Time.deltaTime*5);//沿着direction方向每秒5米运动
    }
    private void Update()
    {
        if (Input.GetMouseButton(0))
        {
            float x = Input.GetAxis("Mouse X");//鼠标在水平方向的滑动增量（相对于上一帧的变化）
            print(x);
        }
        if (Input.GetMouseButton(1))
        {
            float s = Input.GetAxis("Mouse ScrollWheel");
            print(s);
        }
    }
}
